package com.sicheng.algorithm.node;

/**
 * @author zsc
 * @version 1.0
 * @date 2021/9/18 16:10
 */
public class DeleteDuplicationNode {
    public static void main(String[] args) {

        ListNode head = ListNode.initList(new int[]{1, 2, 3, 3, 4, 4, 5, 5});
        ListNode.list(head);
        deleteDuplicationNode(head);
        System.out.println("#######");
        ListNode.list(head);
    }

    public static void deleteDuplicationNode(ListNode head) {
        if (head == null || head.next == null)
            return;

        ListNode current = head;
        while (current != null && current.next != null) {

            if (current.val == current.next.val) {//delete next node
                current.next = current.next.next;
            }
            current = current.next;
        }

    }


}
